package leetcode.editor.cn;

public class _149_MaxPointsOnALine {
    public static void main(String[] args) {
        Solution solution = new _149_MaxPointsOnALine().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int maxPoints(int[][] points) {
            if (points.length <= 2) return points.length;
            int n = points.length;
            int res = 2;
            for (int i = 0; i < n - 1; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = 2;
                    int x1 = points[i][0], y1 = points[i][1];
                    int x2 = points[j][0], y2 = points[j][1];
                    for (int k = 0; k < n; k++) {
                        if (k == i || k == j) {
                            continue;
                        }
                        int x = points[k][0], y = points[k][1];
                        if ((y - y1) * (x - x2) == (y - y2) * (x - x1)) {
                            temp++;
                        }
                    }
                    res = Math.max(res, temp);
                }
            }
            return res;

        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}